package com.zr.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.zr.service.StudentServiceHyx;
import com.zr.service.UserServiceHyx;
import com.zr.serviceImpl.StudentServiceImplHyx;
import com.zr.serviceImpl.UserServiceImplHyx;

public class adminDelStudentControllerHyx extends HttpServlet{

	StudentServiceHyx sService = new StudentServiceImplHyx();
	UserServiceHyx uService = new UserServiceImplHyx();
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doPost(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		req.setCharacterEncoding("UTF-8");
		resp.setCharacterEncoding("UTF-8");
		String[] sids = req.getParameterValues("sids[]");
		for (int i = 0; i < sids.length; i++) {
			int sid =Integer.parseInt(sids[i]);
			//删除学生表学生信息
			boolean flag1 = sService.adminDeleteStudent(sid);
			//删除用户表学生信息
			boolean flag2 = uService.deleteStudentUser(sid);

			PrintWriter pw = resp.getWriter();
			if(flag1&&flag2){
				pw.write("1");
			}else{
				pw.write("0");
			}
			pw.flush();
			pw.close();
		}
	}
}
